package com.samsung.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.samsung.dto.timer.TimerEventDto;
import com.samsung.dto.vote.VoteHistoryDto;
import com.samsung.model.lots.LotsEvent;
import com.samsung.model.lottery.LotteryEvent;
import com.samsung.model.vote.VoteTopic;
import com.samsung.service.lots.LotsService;
import com.samsung.service.lottery.LotteryService;
import com.samsung.service.timer.TimerService;
import com.samsung.service.vote.TopicService;

/**
 * 
 *	@ClassName: IndexController
 *	@Description: 系统首页
 *	@author pu.huang
 *	@date 2015年5月13日 上午9:41:29
 *
 */
@Controller
public class IndexController {

	@Autowired
	private LotteryService lotteryService;
	
	@Autowired
	private LotsService lotsService;
	
	@Autowired
	private TopicService topicService;
	
	@Autowired
	private TimerService timerIndexService;
	
	@RequestMapping(value={"/index", "/"})
	public ModelAndView index() {
		ModelAndView model = new ModelAndView("index");
		
		//默认列表条数
		int max = 5;
		
		//投票列表数据
		List<VoteTopic> newList = topicService.listNewVote(max);
		List<VoteHistoryDto> hotList = topicService.listHotVote(max);
		model.addObject("newList", newList);
		model.addObject("hotList", hotList);
		
		//抽奖列表数据
		List<LotteryEvent> lotteryList = lotteryService.listNewLottery(max);
		model.addObject("lotteryList", lotteryList);
		
		//抽签列表数据
		List<LotsEvent> lotsList = lotsService.listNewLots(max);
		model.addObject("lotsList", lotsList);
		
		//计时列表数据
		List<TimerEventDto> stopWatchInfoList = timerIndexService.getStopWatchInfo(0, max);
		model.addObject("stopWatchInfoList", stopWatchInfoList);
		
		
		return model;
	}

}
